﻿
@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
    <title>天猫淘宝内部优惠券</title>
    <link rel="stylesheet" href="/zhekou/css/common.css" />
    <link rel="stylesheet" href="/zhekou/css/zhekou.css?v=20170317" />
    <script type="text/javascript" src="http://cdn.bootcss.com/fastclick/1.0.6/fastclick.min.js"></script>
    <script type="text/javascript" src="http://cdn.bootcss.com/zepto/1.2.0/zepto.min.js"></script>
    <script type="text/javascript" src="/zhekou/js/common.js"></script>
</head>
<body>
    <div class="wrapper">       
        <div class="search-main">
            <div class="search-area" style="">
                <form action="#" onsubmit="return false;">
                    <div class="inner">
                        <i></i>
                        <input name="search" type="search" id="searchInput" class="search-input" placeholder="搜索正在优惠的商品" value="" />
                    </div>
                </form>
            </div>
            <div class="sort-option-area">
                <ul>
                    <li data-type="0" class="active">综合
                    <li data-type="1">销量
                    <li data-type="3">优惠率
                    <li data-type="2">价格
                </ul>
            </div>
            <div class="tagbox">
                <h3>热门搜索</h3>
                <ul class="search_tag clearfix">

                    <li><a href="/sale/search?Key=短袖">短袖</a></li>
                    <li><a href="/sale/search?Key=T恤">T恤</a></li>
                    <li><a href="/sale/search?Key=防晒衣">防晒衣</a></li>
                    <li><a href="/sale/search?Key=口红">口红</a></li>
                    <li><a href="/sale/search?Key=风扇">风扇</a></li>
                    <li><a href="/sale/search?Key=凉席">凉席</a></li>
                    <li><a href="/sale/search?Key=充电宝">充电宝</a></li>
                    <li><a href="/sale/search?Key=玻璃杯">玻璃杯</a></li>
                    <li><a href="/sale/search?Key=拖鞋">拖鞋</a></li>
                    <li><a href="/sale/search?Key=衬衫">衬衫</a></li>
                    <li><a href="/sale/search?Key=牛仔裤">牛仔裤</a></li>
                    <li><a href="/sale/search?Key=连衣裙">连衣裙</a></li>
                    <li><a href="/sale/search?Key=修容棒">修容棒</a></li>
                    <li><a href="/sale/search?Key=面膜">面膜</a></li>
                    <li><a href="/sale/search?Key=防晒霜">防晒霜</a></li>
                    <li><a href="/sale/search?Key=洗发水">洗发水</a></li>
                    <li><a href="/sale/search?Key=耳机">耳机</a></li>
                    <li><a href="/sale/search?Key=女鞋">女鞋</a></li>
                    <li><a href="/sale/search?Key=文胸">文胸</a></li>
                </ul>
            </div>
                <div class="product-list-area" style="margin-left: 10px;">
                    <div id="productList" class="clearfix"></div>
                    <p class="txt-loading"></p>
                </div>
            </div>
    </div>
    <input type="hidden" id="noDock" value="1" />
    <script type="text/javascript">
        Zepto(function ($) {
            FastClick.attach(document.body);

            var searchInput = $('#searchInput'),
                productList = $('#productList'),
                loadingTxt = $('.txt-loading');


            var page = 0, pagesize = 20, load = 1,sort = 0;

            var _w = $('.wrapper').width(), picH = (_w - 25) / 2;
            if (_w > 500) {
                picH = (_w - 10 - 5 - 5 - 10) / 3;
            }
            var keyword = getQueryString("Key");
            if (keyword != null && keyword!="")
            {

                $(".tagbox").hide();
                searchInput.val(keyword);
            }
            searchInput.focus();
            var channel = 35;
            var listStyle = 1;
            $('.sort-option-area li').on('click', function () {
                var _this = $(this);
                if (!_this.hasClass('active')) {
                    $('.sort-option-area li.active').removeClass('active');
                    _this.addClass('active');

                    sort = _this.data('type');
                    page = 0;
                    load = 1;

                    productList.html('');
                    $('body').scrollTop(0);
                    loadingTxt.html('努力获取中...');
                    getProductList();
                }
            });
            searchInput.on('keypress', function (e)
            {
                var _this = $(this);
                if (e.keyCode == 13 && $.trim(_this.val()) != '')
                {
                    $(".tagbox").hide();
                    productList.html('');
                    load = 1;
                    page = 0;
                    getProductList();
                }
            });

            getProductList();

            /* scroll event start */
            var de = document.documentElement;
            $(document).on('scroll', function () {
                var sH = de.scrollHeight, cH = de.clientHeight;
                if (sH - cH - $('body').scrollTop() <= 400) {
                    getProductList();
                }
            });
            /* scroll event end */

            function getProductList()
            {
                if (!load) {
                    return;
                }
                var q = searchInput.val();
                if (!q || !q.trim()) {
                    return;
                }
                $.ajax({
                    url: '/sale/getZhekouListByCate',
                    type: 'Post',
                    dataType: 'json',
                    data: {
                        'limit': page,
                        'pagesize': pagesize,
                        'cid': 0,
                        'sort': sort,
                        'Key': q
                    },
                    beforeSend: function () {
                        load = 0;
                        loadingTxt.html('努力加载中...');
                    },
                    success: function (data) {
                        if (data.rows.CurrentPageList != null) {
                            createProductList(data.rows.CurrentPageList);
                            if (data.rows.CurrentPageList.length >= pagesize)
                            {
                                $(".sort-option-area").show();
                                page++;
                                load = 1;
                            } else {
                                loadingTxt.html('没有更多商品了');
                            }
                        }
                 
                    }
                });
            }

            function createProductList(pl) {
                var htmlstr = '';
                for (var i = 0, len = pl.length; i < len; i++) {
                    var zk = pl[i];
                    htmlstr += '<a href="/goods/' + zk.auctionId + '.html">';
                    htmlstr += '<div class="product-item-t2" style="width:' + picH + 'px;">';
                    htmlstr += '<div class="pic lazy new" data-original="' + zk.pictUrl + '" style="width: ' + picH + 'px; height: ' + picH + 'px;"></div>';
                    htmlstr += '<p class="title">';
                    //if (zk.post_free == 1) {
                        htmlstr += '<span class="post-free">包邮</span>&nbsp;';
                   // }
                    htmlstr += zk.title + '</p>';

                    htmlstr += '<div class="progress-area">';
                    htmlstr += '<p class="pro-text">已领' + Math.floor(0.98 * 100) + '%</p>';
                    htmlstr += '<div class="pro-container">';
                    htmlstr += '<div data-pro="' + zk.progress + '" class="pro" style="width:' + Math.floor(0.98 * 100) + '%;"></div>';
                    htmlstr += '</div>';
                    htmlstr += '</div>';

                    htmlstr += '<div class="price-area">';
                    htmlstr += '<p class="gap-price"><em class="number-font">' + zk.couponAmount + '</em>元券</p>';
                    htmlstr += '<p class="price">券后价&yen;<em class="number-font">' + (zk.zkPrice - zk.couponAmount).toFixed(1) + '</em></p>';
                    htmlstr += '</div>';
                    htmlstr += '</div>';
                    htmlstr += '</a>';
                }
                productList.append(htmlstr);
                Util.lazyLoad('lazy.new');
                $('.lazy.new').removeClass('new');
            }
        });
        // JavaScript Document
        (function (doc, win) {
            var docEl = doc.documentElement;
            resizeEvt = "orientationchange" in window ? "orientationchange" : "resize",
            recalc = function () {
                var clientWidth = docEl.clientWidth;
                if (!clientWidth) {
                    return
                }
                if (clientWidth > 640) {
                    clientWidth = 640
                }
                docEl.style.fontSize = (clientWidth / 10) + "px";
            };
            if (!doc.addEventListener) {
                return
            }
            win.addEventListener(resizeEvt, recalc, false);
            doc.addEventListener("DOMContentLoaded", recalc, false)
        })(document, window);
        function getQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
            var r = (window.location.search.substr(1).match(reg));
       
            if (r != null) return decodeURI(r[2]);
            return null;

           
        }
    </script>
</body>
</html>
